﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.windows.main {
    import flash.events.*;
    import flash.display.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.views.windows.*;
    import net.wooga.pets.events.windows.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.constants.windows.*;

    public class MainWindowsMediator extends Mediator {

        private var _mainRenderView:MainWindowsContainer;

        public function set windowRenderView(_arg1:MainWindowsContainer):void{
            this._mainRenderView = _arg1;
        }
        override public function onRegister():void{
            this.eventMap.mapListener(eventDispatcher, WindowsEventConstants.ON_WINDOW_VIEW_ADDED_TO_STAGE, this.onWindowViewAddedDetected);
            this.eventMap.mapListener(eventDispatcher, WindowsEventConstants.ON_WINDOW_VIEW_REMOVED_FROM_STAGE, this.onWindowViewRemovedDetected);
            this.eventMap.mapListener(eventDispatcher, WindowsMainViewUpdateEvent.ADD_STANDARD_WINDOW, this.onWindowAddRequest);
        }
        private function onWindowAddRequest(_arg1:WindowsMainViewUpdateEvent):void{
            var _local2:IWindowView = _arg1.window;
            this.view.addChild((_local2 as Sprite));
            if (_local2.options.disableStage){
                this.showClickBlocker();
            };
        }
        private function showClickBlocker():void{
            this.view.graphics.beginFill(0x333333, 0.4);
            this.view.graphics.drawRect(0, 0, this.view.stage.width, this.view.stage.height);
        }
        private function hideClickBlocker():void{
            this.view.graphics.clear();
        }
        private function onWindowViewAddedDetected(_arg1:Event):void{
            var _local2:IWindowView = (_arg1.target as IWindowView);
            if (this.view.numChildren == 1){
                dispatch(new InfoEvent(GameConstants.SUN_HIDE_BUBBLE, GameConstants.SUN_HIDE_BUBBLE));
            };
        }
        private function onWindowViewRemovedDetected(_arg1:Event):void{
            var _local2:IWindowView = (_arg1.target as IWindowView);
            this.doNumChildCheck();
        }
        private function doNumChildCheck():void{
            this.hideClickBlocker();
            if (this.view.numChildren == 0){
                dispatch(new InfoEvent(GameConstants.SUN_SHOW_BUBBLE, GameConstants.SUN_SHOW_BUBBLE));
            };
        }
        private function get view():Sprite{
            return ((this._mainRenderView as Sprite));
        }

    }
}//package net.wooga.pets.views.windows.main 
